﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

static public class UIExtension
{
    /// <summary>
    /// 递增到number的值，
    /// </summary>
    /// <param name="canvasGroup"></param>
    /// <param name="number"></param>
    /// <returns></returns>
    static public async Task AddAlpha(this CanvasGroup canvasGroup, float number, float time,float value=0.1f)
    {
        while (canvasGroup.alpha < number)
        {
            await Task.Delay((int)(time * 1000));
            canvasGroup.alpha += value;
        }
    }

    static public async Task ReduceAlpha(this CanvasGroup canvasGroup, float number, float time, float value = 0.1f)
    {
        while (canvasGroup.alpha > number)
        {
            await Task.Delay((int)(time * 1000));
            canvasGroup.alpha -= value;
        }
    }
}

